package com.yiyang.controller;

import com.yiyang.entity.Result;
import com.yiyang.entity.Room;
import com.yiyang.service.RoomService;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/room")
@Tag(name = "房间接口")
public class RoomController {

    @Autowired
    private RoomService roomService;

    @GetMapping("/get")
    public Result<List<Room>> getRoom(
            @RequestParam(name="currentPage",defaultValue = "1") Integer currentPage,
            @RequestParam(name="pageSize",defaultValue = "10")Integer pageSize,
            @RequestParam(name="num",defaultValue = "")String num){
        return this.roomService.getRoom(currentPage,pageSize,num);
    }

    @PostMapping("/add")
    public Result<Void> addRoom(@RequestBody Room room){
        return this.roomService.addRoom(room);
    }

    @PutMapping("/update")
    public Result<List<Room>> putRoom(@RequestBody Room room){
        return this.roomService.updateRoom(room);
    }

    @DeleteMapping("/delete")
    public Result<Void> deleteRoom(String id){
        return this.roomService.deleteRoom(id);
    }


}
